﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VINETLIFE.BL;
using VINETLIFE.DO;
using System.Data;

namespace VINETLIFE.Module
{
    public partial class ucInfoUnderSlide : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                rptSetTopProductDataSource();
            }
        }
        protected void rptSetTopProductDataSource()
        {
            DataTable dtSlide = new cmsProductBL().SelectFrontPage(1, -1, -1, -1, 1);
            
            
            rptSetTopProduct.DataSource = dtSlide;
            rptSetTopProduct.DataBind();
            if (dtSlide.Rows.Count > 0)
            {
                float price = Convert.ToInt32(dtSlide.Rows[0]["Price"]);
                float saleprice = Convert.ToInt32(dtSlide.Rows[0]["SalePrice"]);
                int phantram = (int)(100 - (saleprice / price) * 100);
                lblSaleprice.Text = "-" + phantram + " %";
                DateTime timeCountDown = new DateTime();
                timeCountDown = (DateTime)dtSlide.Rows[0]["PromotionEndDate"];
                lblCountDown.Text = "<script type='text/javascript'>$(function () {var austDay = new Date();austDay = new Date(" + timeCountDown.Year + "," + (timeCountDown.Month - 1) + "," + timeCountDown.Day + "," + timeCountDown.Hour + "," + timeCountDown.Minute + "," + timeCountDown.Second + ");$('#defaultCountdown').countdown({ until: austDay, format: 'HMS',compact: true,description: ''});$('#year').text(austDay.getFullYear());});</script>";
                
            }
        }
        protected string FriendlyUrl(string s)
        {
            return Ultility.Change_AV(s);
        }
    }
}